<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/clip/ZeroClipboard.js"></script> 
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >  
<script type="text/javascript">
    $(function(){
        window.alert = Boxy.alert;
    });
</script>
 
    <div class="admin_nrtop">
        <div class="yundantopleft">
            <div class="yundancz">
                <div class="nui-toolbar-item">
                    <div class="nui-btn ">
                        <a href="<?= $this->referer ?>" class="nui-btn-text"><span>&lt;&lt;</span>返回</a>
                    </div>
                </div>                    
                <div class="nui-toolbar-item">
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" id='splitOrder' class="nui-btn-text">拆分</a>
                    </div>
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" id="reserveOrder" class="nui-btn-text reserveOrder" >订单预订</a>
                    </div>
                    <div class="nui-btn" id="editupdete">
                        <a href="javascript:void(0)" class="nui-btn-text rxl" id="editStatus">修改状态<i></i></a>
                        <div class="ztlist" style="display:none;">
                            <ul>
                                <?php foreach ($this->statusAll as $key => $statusVal) { ?>
                                    <li><a href="javascript:void(0)" class="editInterior" name="<?php echo $key; ?>"><?php echo $statusVal; ?></a></li>
                                <?php }?>
                            </ul>
                        </div>
                    </div>
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" class="nui-btn-text showProblem">设置问题</a>
                    </div>
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" id='getLogistics' class="nui-btn-text">获取物流</a>
                    </div>
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" id='orderTrack' class="nui-btn-text" target="_block">订单跟踪</a>
                    </div>
                    <div class="nui-btn ">
                        <a href="javascript:void(0)" id="cancel" class="nui-btn-text">取消</a>
                    </div>
                </div>         
            </div>
        </div>
        <div class="yundantopright">
            <p>用户ID：<?php echo $this->order->UserId; ?><input type="hidden" id="allOrderId" name="allOrderId" value="<?php echo $this->order->Id?>" /></p>
        </div>
        <div class="buzhou" style="clear:both">
            <div class="bzbox">
                <table>
                    <tr>
                        <?php
                        $interiorall = $this->order->StatusCorrect;
                        foreach ($interiorall as $key => $interiorval) {
                            $orderLog = Application_Model_Tracking::getOneByObjectTypeIdOperateType(Application_Model_DomainobjectType::ObjectType_Order, $this->order->Id, $key)
                            ?>
                            <td <?php echo $orderLog ? 'class="bz_wanl"' : ""; ?>>
                                <div class="bzloading">
                                    <div class="dian"><?php echo ($orderLog ? '<a href="javascript:void(0)"><i></i><span>'.$interiorval[1] : '<i></i><span>'.$interiorval[0]).'</span></a>'; ?></div>
                                    <?php if ($orderLog) { ?>
                                        <div class="bzxiangbox" style="display: none;">
                                            <div class="xjiantou"></div>
                                            <div class="xianginfo">
                                                <ul>
                                                    <li><label>处理时间：</label><em><?php echo $orderLog->dateAdd; ?></em></li>
                                                    <li><label>责任人：</label><em><?php echo $orderLog->operator; ?></em></li>
                                                </ul>
                                            </div>
                                        </div>
                                    <?php } ?>
                                </div>
                            </td>
                        <?php } ?>
                            <td <?php echo $this->order->status == Application_Model_Order::STATUS_INSTORE ? 'class="bz_wanr"' : ""; ?>></td>
                    </tr>
                </table>
            </div>
            <div class="bzxiang"></div>
        </div>
    </div>    
    <div class="yundan_top">
        <table class="yunxinxi">
            <tr>
                <td class="ydleft">
                    <div class="zhuangtai">
                        <i></i><h1><?php echo $this->order->StatusNames;?></h1>
                        <?php if($this->order->Isdelete == 1){?><h1 style="color:#c00;margin-left: 10px;">[已删除]</h1><?php }?>
                        <?php if($this->order->problem == Application_Model_Order::Problem_Appear){?><h1 style="color:#F60;margin-left: 10px;">[问题]</h1><?php }?>
                    </div>
                    <div class="shouli">
                        <?php if($this->order->Isdelete != 1){ ?>
                            <?php if($this->order->Status == Application_Model_Order::STATUS_PAID){ ?>
                                <a class="anvbotton5" href="javascript:void(0)" id="hear"><span>受理</span></a>
                            <?php }?>
                        <?php }?>
                    </div>
                </td>
                <td class="ydtopline">
                    <div class="zhtailan">
                        <label>状态栏：</label>
                        <div class="ydtishi">
                            <?php if($this->order->problem == Application_Model_Order::Problem_Default || $this->order->problem == "" || $this->order->problem == null){ ?>
                                <a class="showProblem" href="javascript:void(0)" title="设置问题" style="background:url('/admins/images/icons/setProblem.ico');" >设置问题</a>
                            <?php } else if ($this->order->problem == Application_Model_Order::Problem_Appear || $this->order->problem == Application_Model_Order::Problem_User){ ?>
                                <a class="ts3 showProblem" href="javascript:void(0)" title="问题包裹">问题包裹</a>
                            <?php } else if ($this->order->problem == Application_Model_Order::Problem_Complete){ ?>
                                <a class="ts3_ showProblem" href="javascript:void(0)" title="问题解决">问题解决</a>
                            <?php } ?>
                            <a class="reserveOrder" href="javascript:void(0)" title="预定订单" style="background:url('/admins/images/icons/dateShip.ico');" >预定订单</a>
                            <?php if($this->order->FinancialCheck){ ?>
                                <a class="setHandwork" href="javascript:void(0)" title="手工处理" style="background:url('/admins/images/icons/yellow_money.png');">手工处理</a>
                            <?php } else { ?>
                                <a class="setHandwork" href="javascript:void(0)" title="手工处理" style="background:url('/admins/images/icons/blue_money.png');" >手工处理</a>
                            <?php } ?>
                            <?php if($this->order->IsAbnormal == Application_Model_Order::Abnormal_Less || $this->order->IsAbnormal == Application_Model_Order::Abnormal_Error || $this->order->IsAbnormal == Application_Model_Order::Abnormal_Damage){ ?>
                                <a class="abnormalico" href="javascript:void(0)" title="异常代购" style="background:url('/admins/images/icons/yellow.ico');" >异常代购</a>
                            <?php } else if($this->order->IsAbnormal == Application_Model_Order::Abnormal_Solve) { ?>
                                <a class="ts4 abnormalico" href="javascript:void(0)" title="异常解决" >异常解决</a>
                            <?php } ?>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="ydleft">
                    <table>
                        <tr>
                            <td class="xleft">订单编号：</td>
                            <td class="xlright"><?php echo $this->order->OrderNum;?></td>
                            <td class="xleft">代购标识：</td>
                            <td class="xlright"><a href="javascript:void(0)" class="soleNo"><?php echo $this->order->SoleNo;?></a></td>
                        </tr>
                        <tr>
                            <td class="xleft">用户昵称：</td>
                            <td class="xlright"><?php echo $this->order->User->Nikename; ?></td>
                            <td class="xleft">仓库号：</td>
                            <td class="xlright"><a href="/admini/manageuser/userdetail/id/<?php echo $this->order->UserId; ?>" target="_blank" class="indexa"><?php echo $this->order->User->Storeno; ?></a></td>
                        </tr>
                        <tr>
                            <td class="xleft">购买帐号：</td>
                            <td class="xlright"><?php echo $this->order->procureNo?'<a href="javascript:void(0)" target="_block" class="indexa buyexpresstrack">'.($this->order->TaoBao?$this->order->TaoBao->taobaoname:"非淘宝订单")."</a>":"暂无"; ?></td>
                            <td class="xleft"></td>
                            <td class="xlright"></td>
                        </tr>
                        <tr>
                            <td class="xleft">受理人：</td>
                            <td class="xlright">
                                <?php echo $this->order->operator?$this->order->operator:"暂无";?>
                                <?php if($this->order->Status != Application_Model_Order::STATUS_PAID && $this->order->Isdelete != 1  && $this->order->Status != Application_Model_Order::STATUS_CANCEL && $this->order->operator != Uuch_Util::getUserNikeName()){ ?>
                                    <a href="javascript:void(0)" class="indexa editOperator">更改受理人</a>
                                <?php } ?></td>
                            <td class="xleft"></td>
                            <td class="xlright"></td>
                        </tr>
                    </table>
                </td>
                <td class="ydtopline sdq" rowspan="2">
                    <table class="yddizhi">
                        <tr>
                            <td class="dzl" style="width:100px;">最后更新时间：</td>
                            <td><?php echo $this->order->dateConfrim; ?></td>
                        </tr>
                        <tr>
                            <td class="dzl">预定发货时间：</td>
                            <td><?php echo $this->order->DateShip?$this->order->DateShip:"暂无";?></td>
                        </tr>
                        <tr>
                            <td class="dzl">付款时间：</td>
                            <td><?php echo $this->order->datePaid; ?></td>
                        </tr>
                        <tr>
                            <td class="dzl">提交时间：</td>
                            <td><?php echo $this->order->dateCreated; ?></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <div class="ydbottom">
        <?php if($this->order->comment){ ?>
            <div class="youqiliuyan">
                <div class="lanmu">
                    <h2>运单内部备注</h2>
                </div>
                <div class="yqly">
                    <?php echo $this->order->comment;?>
                </div>
            </div>
        <?php }?>
        <?php if($this->order->user->remark){ ?>
            <div class="youqiliuyan">
                <div class="lanmu">
                    <h2>用户备注</h2>
                </div>
                <div class="yqly">
                    <?php echo "<p><b>用户备注：</b>".$this->order->user->remark."</p>";?>
                </div>
            </div>
        <?php }?>
    </div>
    <div class="wupintable" style="width: 1700px;margin: 5px 25px;">
        <div class="biaotbody">
            <table>
                <tr>
                    <th class="li305"><div class="lileft">&nbsp;</div></th>
                    <th class="li35"><div class="lileft">物品信息</div></th>
                    <th class="li9"><div class="lileft">单价</div></th>
                    <th class="li9"><div class="lileft">数量</div></th>
                    <th class="li9"><div class="lijz">总价</div></th>
                </tr>
            </table>
        </div>
        <div class="table">
            <table>
                <?php $index = 2; $shipUrl = "";$arrproduct = array();
                    echo "<tr id='tr_" . $this->order->Id . "_1'>";
                    if($this->order->shipdetail){
                        foreach ($this->order->shipdetail as $key => $val) {
                            if (count($this->order->shipdetail) > 1) {
                                if ($key > 0) {
                                    echo "<tr id='tr_" . $this->order->Id . "_$index'>";
                                    $index+=1;
                                }
                            }
                            $productd = $val->byproductd;
                            if ($key == 0){
                                $shipUrl = $productd->url;
                            }
                            $image = $productd->image ? $productd->image : $productd->remoteImage;
                            $arrimage = explode('"', $image);
                            if(count($arrimage)>1){
                                $imgUrl = $arrimage[1];
                            } else {
                                $imgUrl = $image;
                            } 
                            if(strpos($shipUrl,"taobao")>0 || strpos($shipUrl,"tmall")>0){
                                $extendUrl = 'http://trade.taobao.com/trade/detail/trade_item_detail.htm?spm=a1z09.2.9.27.yegbD7&bizOrderId=' . $this->order->procureNo;
                            } else {
                                $extendUrl = $shipUrl;
                            }
//                            $arrproduct[$val->Id]["name"] = mb_substr($val->ProductName, 0, 10, 'utf-8');
                            if($val->Status != 1){
                                $arrproduct[$val->Id]["name"] = $val->ProductName;
                                $arrproduct[$val->Id]["alias"] = Application_Model_Product::parsePropertyAlias($productd->PropertyAlias);
                                $arrproduct[$val->Id]["num"] = $val->quantity;
                                $arrproduct[$val->Id]["img"] = $imgUrl;
                            }
                ?>
                                <td class="li305">
                                    <div class="lileft bianhao">
                                        <?php if($this->order->Status == Application_Model_Order::STATUS_CONFRIM  && $this->order->Isdelete != 1){?>
                                            <div style="float:left;font-size: 16px;margin-right: 10px;margin-top: 10px;">
                                                <?php if( $val->Status == 1){} else {?><input name="SplitCheck" type="checkbox" id="SplitCheck<?php echo $val->Id;?>" value="<?php echo $val->Id;?>" class="SplitCheck" /><?php } ?>
                                                <span style="margin-left:5px;"><?php echo $key+1;?></span>
                                            </div>
                                        <?php } ?>
                                    </div>
                                </td>
                                <td class="li35">
                                    <?php if ($this->order->status != Application_Model_Order::STATUS_PAYING && $this->order->status != Application_Model_Order::STATUS_PAID && $this->order->status != Application_Model_Order::STATUS_CANCEL && $this->order->Isdelete != 1) { ?>
                                        <?php if($this->order->status == Application_Model_Order::STATUS_CONFRIM && $this->order->operator != Uuch_Util::getUserNikeName()){?>
                                            <div style="float:left;width: 55px;">
                                                <img src="<?php echo $imgUrl; ?>" width="60px" height="60px" style="vertical-align:middle;"/>
                                            </div>
                                            <div style="float:left;width: 90%;">&nbsp;&nbsp;<?php echo $val->productName; ?></div>
                                            <div style="float:left;color:#666;width: 90%;">&nbsp;&nbsp;<?php echo Application_Model_Product::parsePropertyAlias($productd->PropertyAlias); ?></div>
                                        <?php } else { ?>
                                            <div style="float:left;width: 55px;">
                                                <a href="<?php echo $val->taoBaoUrl?$val->taoBaoUrl:$productd->url; ?>" target="_blank">
                                                    <img src="<?php echo $imgUrl; ?>" width="60px" height="60px" style="vertical-align:middle;"/>
                                                </a>
                                            </div>
                                            <div style="float:left;width: 90%;">
                                                &nbsp;&nbsp;<a href="<?php echo $val->taoBaoUrl?$val->taoBaoUrl:$productd->url; ?>" target="_blank" class="indexa"><?php echo $val->productName; ?></a>
                                            </div>
                                            <div style="float:left;color:#666;width: 90%;">&nbsp;&nbsp;<a href="<?php echo $productd->url ?>" target="_blank"><?php echo Application_Model_Product::parsePropertyAlias($productd->PropertyAlias); ?></a></div>
                                        <?php } ?>
                                    <?php } else { ?>
                                        <div style="float:left;width: 55px;">
                                            <img src="<?php echo $imgUrl; ?>" width="60px" height="60px" style="vertical-align:middle;"/>
                                        </div>
                                        <div style="float:left;width: 90%;">&nbsp;&nbsp;<?php echo $val->productName; ?></div>
                                        <div style="float:left;color:#666;width: 90%;">&nbsp;&nbsp;<?php echo Application_Model_Product::parsePropertyAlias($productd->PropertyAlias); ?></div>
                                    <?php } ?>
                                    <div style="float:left;color:#666;width: 90%;padding-left: 8px;">商品备注：<?php echo $val->comment ? $val->comment : "(无)"; ?></div>
                                    <div class="ydtishi" style="width: 15px;height: 15px;float: left;"><a class="ts1 addRemark" href="javascript:void(0)" title="添加备注" name="<?php echo $val->Id; ?>">添加备注</a></div>
                                    <div style="float:left;color:#c00;width: 90%;" id="itemDescription<?php echo $val->id; ?>"><?php echo $val->description ? $val->description : ""; ?></div>
                                </td>
                                <td class="li9">
                                    <div class="lileft">
                                    <?php echo $val->price; ?>
                                    <?php
                                        if ($val->status != 1) {
                                            if ($this->order->status != Application_Model_Order::STATUS_CANCEL && $this->order->status != Application_Model_Order::STATUS_INSTORE && $this->order->status != Application_Model_Order::STATUS_PAYING && $this->order->status != Application_Model_Order::STATUS_PAID && count($this->order->shipdetail) > 1) {
                                                if( $this->order->status == Application_Model_Order::STATUS_CONFRIM && $this->order->operator == Uuch_Util::getUserNikeName()){
                                                ?>
                                                <a href="javascript:void(0);" name="<?php echo $val->id; ?>"  class="indexa SingleRetuenMoney">
                                                    <div id="SingleRetuenMoney<?php echo $val->id; ?>">单项退款</div></a>
                                                <?php } else if( $this->order->status != Application_Model_Order::STATUS_CONFRIM) { ?>
                                                <a href="javascript:void(0);" name="<?php echo $val->id; ?>"  class="indexa SingleRetuenMoney">
                                                    <div id="SingleRetuenMoney<?php echo $val->id; ?>">单项退款</div></a>
                                            <?php } }
                                        } else {
                                            ?>
                                            <div><font color="green">已退款</font></div>
                                            <?php
                                        }
                                        ?>
                                    </div>
                                </td>                                
                                <td class="li9">
                                    <div class="lileft"><?php echo $val->quantity; ?></div>
                                </td>   
                                <?php if ($key == 0) { ?>
                                    <td class="li9" rowspan="<?php echo count($this->order->shipdetail); ?>" style="border-left: #d4dae2 solid 1px;">
                                        <div class="lijz">
                                        ￥<?php echo $this->order->sum; ?> 
                                        <?php if ((int) ($this->order->shipFee) > 0) { echo "<br><font color='grey'>含运费：" . $this->order->shipFee . "</font>"; } ?>
                                        </div>
                                    </td>
                                <?php } ?>  
                    <?php } }?>
            </table>
        </div>    
    </div>
    <div class="ydbottom">
        <?php if($this->order->status >= Application_Model_Order::STATUS_CONFRIM){ ?>
            <div class="chuku">
                <div class="lanmu">
                    <h2>订单流程</h2>
                </div>
                <?php if(($this->order->status == Application_Model_Order::STATUS_CONFRIM) && $this->order->Isdelete != 1){ ?>
                    <div class="lcbox">
                        <table class="lcks" >
                            <tr>
                                <td class="lcleft"><p>待下单</p></td>
                                <td>
                                    <div class="qudao">
                                        <dl>
                                            <dt>订单号：</dt>
                                            <dd>
                                                <input type="textbox" id="procureNo" name="procureNo" value="" />
                                            </dd>
                                        </dl>
                                        <div class="lctijiao">
                                            <a class="anvbotton5" href="javascript:void(0)" id="setProcure"><span>确认</span></a>
                                        </div>
                                    </div> 
                                </td>
                            </tr>
                        </table>
                    </div>
                <?php }?>
                <?php if($this->order->Status >= Application_Model_Order::STATUS_UNSEND && $this->order->procureNo != ""){?>
                    <div class="lcbox">
                        <table class="lcwc">
                            <tr>
                                <td class="lcleft">
                                    <p class="yixz"><i></i>已下单</p>
                                </td>
                                <td>
                                    <div class="qudao">
                                        <dl>
                                            <dt>订单号：</dt>
                                            <dd><?php echo $this->order->ProcureNo; ?></dd>
                                        </dl>
                                    </div>
                                </td>
                            </tr> 
                        </table>
                    </div>
                <?php }?>
                <?php if(($this->order->Status == Application_Model_Order::STATUS_UNSEND || $this->order->Status == Application_Model_Order::STATUS_OUTTIME_UNSEND) && $this->order->logisticsNo == "" && $this->order->Isdelete != 1){?>
                    <div class="lcbox">
                        <table class="lcwc">
                            <tr>
                                <td class="lcleft"><p>待卖家发货</p></td>
                                <td>
                                    <div class="qudao">
                                        <dl>
                                            <dt>物流信息：</dt>
                                            <dd>
                                                <select name="logistics" id="logistics">
                                                    <?php foreach ($this->expresscomp as $expresscomp) { ?>
                                                            <option value="<?php echo $expresscomp->id; ?>"><?php echo $expresscomp->word . '_' . $expresscomp->name; ?></option>
                                                    <?php } ?>
                                                </select>
                                                <input type="text" id="logisticsNo" name="logisticsNo" value="" />
                                            </dd>
                                        </dl>
                                        <div class="lctijiao">
                                            <a class="anvbotton5" href="javascript:void(0)" id="setLogistics"><span>确认</span></a>
                                        </div>
                                    </div> 
                                </td>
                            </tr>
                        </table>
                    </div>
                <?php }?>
                <?php if($this->order->Status >= Application_Model_Order::STATUS_SELLER_SENDED && $this->order->Status != Application_Model_Order::STATUS_SUBSCRIBE  && $this->order->Status != Application_Model_Order::STATUS_OUTTIME_UNSEND){?>
                    <div class="lcbox">
                        <table class="lcwc">
                            <tr>
                                <td class="lcleft">
                                    <p class="yixz"><i></i>卖家已发货</p>
                                </td>
                                <td>
                                    <div class="qudao">
                                        <dl>
                                            <dt>物流信息：</dt>
                                            <dd><?php echo "[".$this->order->LogisticsBy->Name."]".$this->order->LogisticsNo;?></dd>
                                        </dl>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                <?php }?>
                <?php if(($this->order->Status == Application_Model_Order::STATUS_SELLER_SENDED || $this->order->Status == Application_Model_Order::STATUS_OUTTIME_INSTORE) && $this->order->Isdelete != 1){?>
                    <div class="lcbox">
                        <table class="lcks" >
                            <tr>
                                <td class="lcleft"><p>待入库</p></td>
                                <td>
                                    <div class="qudao">
                                        <div class="lctijiao">
                                            <a class="anvbotton5" href="javascript:void(0)" id="setInStore"><span>设置已入库</span></a>
                                        </div>
                                    </div> 
                                </td>
                            </tr>
                        </table>
                    </div>
                <?php }?>
                <?php if($this->order->Status == Application_Model_Order::STATUS_INSTORE){?>
                    <div class="lcbox">
                        <table class="lcwc">
                            <tr>
                                <td class="lcleft">
                                    <p class="yixz"><i></i>已入库</p>
                                </td>
                                <td>
                                    <div class="qudao">
                                        <?php foreach($this->order->StoreBylogistics as $storeVal){ ?>
                                        <dl>
                                            <dt>商品仓库编号：</dt>
                                            <dd><?php echo $storeVal->Barcode;?></dd>
                                        </dl>
                                        <?php } ?>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                <?php }?>
            </div>
        <?php }?>
    </div>     
    <div class="yundan_top">
        <table class="yunxinxi">
            <tr>
                <td class="ydleft">
                    <div class="zhtailan">
                        <label>操作日志：</label>
                        <a class="addLog" href="javascript:void(0)" title="添加日志" style="background:url('/admins/images/icons/add.ico');float: left;height: 16px;width: 16px;text-indent: -100000px;display: inline;margin-left: 10px;" >添加日志</a>
                    </div>
                </td>
                <td class="ydtopline">
                    <div class="zhtailan">
                        <label>物流跟踪：</label>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="ydleft">
                    <div class="wupintable operatortrack" style="width: 730px;height: 400px;overflow: auto;">
                        <div class="biaotbody">
                            <table>
                                <tr>
                                    <th class="li15"><div class="lileft">时间</div></th>
                                    <th class="li15"><div class="lileft">操作人</div></th>
                                    <th class="li35"><div class="lileft">操作描述</div></th>
                                    <th class="li9"><div class="lileft">用户是否可见</div></th>
                                </tr>
                            </table>
                        </div>
                        <div class="table operatortrackcontent">
                            <?php if($this->tracklog){ ?>
                                <table>
                                    <tbody>
                                        <?php  foreach ($this->tracklog as $vallog) { ?>
                                            <tr>
                                                <td class='li15' style='font-size:12px;'>
                                                    <div class='lileft bianhao'><?php echo $vallog->dateAdd;?></div>
                                                </td>
                                                <td class='li15' style='font-size:12px;'>
                                                    <div class='lileft bianhao'><?php echo $vallog->operator;?></div>
                                                </td>
                                                <td class='li35' style='font-size:12px;'>
                                                    <div class='lileft bianhao'><?php echo $vallog->content;?></div>
                                                </td>
                                                <td class='li9' style='font-size:12px;'>
                                                    <div class='lileft bianhao'><?php echo $vallog->IsUser;?></div>
                                                </td>
                                            </tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            <?php } else { echo "暂无操作"; } ?>
                        </div>    
                    </div>
                </td>
                <td class="ydtopline sdq" rowspan="2">
                    <div class="wupintable niumentrack" style="width: 900px;height: 400px;overflow: auto;">
                        <div class="biaotbody">
                            <table>
                                <tr>
                                    <th class="li9"><div class="lileft">时间</div></th>
                                    <th class="li15"><div class="lileft">位置</div></th>
                                    <th class="li35"><div class="lileft">描述</div></th>
                                </tr>
                            </table>
                        </div>
                        <div class="table niumentrackcontent">
                            <?php if($this->order->logisticsNo != ""){ ?>
                                物流状态加载中...
                                <script type="text/javascript">
                                    $(function(){
                                        $.post('/admini/purchase/getingexpress', {'id':<?= $this->order->Id ?>}, function(data){
                                            if(data.content){
                                                var html = "<table><tbody>";
                                                $.each(data.content,function(key,val){
                                                    html += "<tr><td class='li9' style='font-size:12px;'><div class='lileft bianhao'>"+val.DATETIME+"</div></td>";
                                                    html += "<td class='li15' style='font-size:12px;'><div class='lileft bianhao'>"+val.PLACE+"</div></td>";
                                                    html += "<td class='li35' style='font-size:12px;'><div class='lileft bianhao'>"+val.INFO+"</div></td></tr>";
                                                });
                                                html += "</tbody></table>";

                                                $(".niumentrackcontent").html(html);
                                                $(".niumentrack").show();
                                                $(".mingxi").hide();
                                            } else {
                                                $(".mingxi").text("无法获取物流信息 ");
                                            }
                                        }, 'json');
                                    })
                                </script>
                            <?php } else {
                                echo "暂无数据";
                            } ?>
                        </div>    
                    </div>
                </td>
            </tr>
        </table>
    </div>
<style>
    .wt_top .wt_nav li a {padding: 1px 10px 0 10px;}
    .bColor{background-color: #b6c4d8 ;}
    .abnormalTr{border-bottom: #c00 solid 1px;}
</style>
<div class="tanchuang" style="display:none;width: 760px;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd">订单操作</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wt_top">
    	<div class="wt_nav">
            <ul>
            	<li class="wt_on"><a href="javascript:void(0)" id="splitOrderTitle">订单拆分</a></li>
                <li><a href="javascript:void(0)" id="reserveOrderTitle">订单预订</a></li>
                <li><a href="javascript:void(0)" id="isProblemTitle">订单问题</a></li>
                <li><a href="javascript:void(0)" id="addRemarkTitle">添加备注</a></li>
                <li><a href="javascript:void(0)" id="handworkTitle">手工处理</a></li>
                <li><a href="javascript:void(0)" id="abnormalTitle">异常处理</a></li>
                <li><a href="javascript:void(0)" id="addLogTitle">添加日志</a></li>
            </ul>
        </div>
    </div>
    <div class="wenti_box" id="splitOrderConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <?php foreach($arrproduct as $splitKey => $splitVal){ ?>
                <tr class="splitTr splitTr<?php echo $splitKey;?>">
                    <td style="width: 420px;" class="w0">
                        <div style="float:left;width: 55px;">
                            <img src="<?php echo $splitVal["img"]; ?>" width="50px" height="50px" style="vertical-align:middle;"/>
                        </div>
                        <div style="float:left;width: 80%;">&nbsp;&nbsp;<?php echo $splitVal["name"];?></div>
                        <div style="float:left;color:#666;width: 80%;">&nbsp;&nbsp;<?php echo $splitVal["alias"];?></div>
                    </td>
                    <td style="width: 80px;"><div class="liright" style="padding-right: 0px;">拆分数量：</div></td>
                    <td style="width: 150px;"><input type="text" id="splitNum<?php echo $splitKey;?>" name="splitNum" value="<?php echo $splitVal["num"];?>" goodsId="<?php echo $splitKey;?>" onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/></td>
                </tr>
                <?php } ?>
                <tr>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 200px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subSplitOrder"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)"  class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="wenti_box" id="reserveOrderConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">预订时间：</td>
                    <td style="width: 420px;" class="w0"><input type="text" id="reserveTime" name="reserveTime" value="" onClick="WdatePicker()"  readonly/></td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">预订原因：</td>
                    <td style="width: 420px;" class="w0"><textarea id="reserveCause" name="reserveCause" style="width:390px;height: 60px;"></textarea></td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 100px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subReserveOrder"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)"  class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="wenti_box" id="handworkConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">类型：</td>
                    <td style="width: 420px;" class="w0">
                        <select id="hendworkType" name="hendworkType">
                            <option value="<?php echo Application_Model_FinancialCheckItem::Money_Need;?>">扣款</option>
                            <option value="<?php echo Application_Model_FinancialCheckItem::Money_Add;?>">充值</option>
                        </select></td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">金额：</td>
                    <td style="width: 420px;" class="w0"><input type="text" id="handworkMoney" name="handworkMoney" value=""/>元</td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">原因：</td>
                    <td style="width: 420px;" class="w0"><textarea id="handworkReason" name="handworkReason" style="width:390px;height: 60px;"></textarea></td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 100px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subHandworkr"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)" class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="checkHistory" style="width: 93%;float: left;margin-left: 50px;">
                            
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="wenti_box" id="isProblemConent" style="display: none;">
        <div class="wt_center" style="height:300px;">
            
        </div>
        <div style="margin-left:20px;margin-top: -5px;margin-bottom: 5px;">
            <span>
                <input type="checkbox" onclick="repayHandle(this)" value="0" name="repay" id="repay">补交金额:
                <input type="text" name="repaysum" readonly="" id="repay-sum" style="width:50px" value="">
            </span>
        </div>
        <div class="wt_caozuo" style="width:738px;">
            <textarea name="content" cols="" rows="" id="content" style="width:670px;"></textarea>
            <input type="hidden" id="orderProblemId" name="orderProblemId" value="" />
            <a class="wt_liuyan" id="subIsProblem" href="javascript:void(0);"><span>留言</span></a>
        </div>
        <a class="indexa SolveComplete" href="javascript:void(0);" style="float:right;margin-right: 20px;padding: 8px;"><span>问题解决</span></a>
    </div>
    <div class="wenti_box" id="addRemarkConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <tr>
                    <td style="width: 120px;text-align: right;padding-right: 20px;">悠奇备注：</td>
                    <td style="width: 420px;" class="w0">
                        <textarea id="remark" name="remark" style="width:390px;height: 60px;"></textarea>
                    </td>
                </tr>
                <tr class='content_bottom'>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 200px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subAddRemark"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)"  class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div class="wenti_box" id="abnormalConent" style="display: none;">
        <div class="wt_center" style="height:300px;margin: 10px 10px 5px 10px;">
            
        </div>
        <div class="wt_type" style="height:30px;width: 100%;display: none;">
            <ul>
                <li style="float: left;width: 70px;padding: 5px 0;margin-left: 10px;">
                    <label>处理类型：</label></li>
                <li style="float: left;width: 90px;padding: 5px 0;">
                    <label><input id="isAbnormal1" name="isAbnormal" type="radio" value="0" checked="checked">异常跟踪</label></li>
                <li style="float: left;width: 90px;padding: 5px 0;">
                    <label><input id="isAbnormal2" name="isAbnormal" type="radio" value="1">异常解决</label></li>
                <li style="float: right;width: 120px;margin-top: 10px;margin-right: 10px;">
                    <a class="indexa loss" href="javascript:void(0);"><span>登记代购人员出错</span></a></li>
            </ul>
        </div>
        <div class="wt_caozuo" style="width:738px;">
            <textarea name="abnormalCause" cols="" rows="" id="abnormalCause" style="width:670px;"></textarea>
            <input type="hidden" id="abnormalId" name="abnormalId" value="" />
            <a class="wt_liuyan" id="subAbnormal" href="javascript:void(0);"><span>留言</span></a>
        </div>
        <a class="indexa SolveAbnormalId" href="javascript:void(0);" style="float:right;margin-right: 20px;padding: 8px;"><span>异常解决</span></a>
        <span class="lossLog" style="float:right;margin-right: 20px;padding: 8px;"></span>
    </div>
    <div class="wenti_box" id="addLogConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">时间：</td>
                    <td style="width: 420px;" class="w0"><input type="text" id="addLogTime" name="addLogTime" value="<?php echo date("Y-m-d H:i:s");?>"  /></td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">日志内容：</td>
                    <td style="width: 420px;" class="w0"><textarea id="addLogContent" name="addLogContent" style="width:390px;height: 60px;"></textarea></td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">用户是否可见：</td>
                    <td style="width: 420px;" class="w0">
                        <select id="logIsVisible" name="logIsVisible">
                            <?php foreach ($this->userVisible as $visibleKey => $visibleVal) { ?>
                            <option value="<?php echo $visibleKey; ?>"><?php echo $visibleVal;?></option>
                            <?php }?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 100px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subAddLog"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)"  class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
     <div class="wenti_box" id="lossConent" style="display: none;">
        <div class="wt_center table" style="width:700px;">
            <table>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">下单人：</td>
                    <td style="width: 420px;" class="w0"><input type="text" id="lossUser" name="lossUser" value=""  readonly/></td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">金额：</td>
                    <td style="width: 420px;" class="w0"><input type="text" id="lossMoney" name="lossMoney" value=""/>元</td>
                </tr>
                <tr>
                    <td style="width: 180px;text-align: right;padding-right: 20px;">原因：</td>
                    <td style="width: 420px;" class="w0"><textarea id="lossReason" name="lossReason" style="width:390px;height: 60px;"></textarea></td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="lctijiao" style="width: 100px;float: left;margin-left: 200px;">
                            <a class="anvbotton5" href="javascript:void(0)" id="subLost"><span>确认</span></a>
                        </div>
                        <div class="nui-btn " style="width: 50px;float: left;padding-top: 12px;">
                            <a href="javascript:void(0)" class="nui-btn-text retanchuang">取消</a>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <div class="checkHistory" style="width: 93%;float: left;margin-left: 50px;">
                            
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"><input type="hidden" id="orderId" name="orderId" value="" /></div>
<script>
    $(function(){
        $(".buyexpresstrack").attr("href","<?php echo $extendUrl;?>");
        $("#orderTrack").attr("href","<?php echo $extendUrl;?>");
        
        $(".dian").mouseenter(function(){
           $(this).next("div").show();
        });
        $(".bzloading").mouseleave(function(){
            $(".bzloading .bzxiangbox").hide();
        });
        $("#editStatus").click(function(){
            $("#editupdete").addClass("nuion");
            $(this).next("div").show();
        });
        
        $(document).bind("click",function(e){
            var target  = $(e.target);
            if(target.closest("#editupdete").length == 0){
                $("#editupdete").removeClass("nuion");
                $(".ztlist").hide();
            }
        });
        <?php if($this->order->Isdelete == null || $this->order->Isdelete == 0) { ?>
            <?php if($this->order->Status == Application_Model_Order::STATUS_PAID){ ?>
                $('#hear').click(function(){
                    var id = $("#allOrderId").val();
                    $.ajax({
                        type: 'POST',
                        url: '/admini/purchase/setconfrim/id/' + id,
                        success: function(data) {
                            if(data == 1){
                                alert("受理成功");
                            }else{
                                alert("发生未知错误。")
                            }
                            location.reload();
                        }
                    });
                    return false;
                });
            <?php }?>
            <?php if($this->order->Status == Application_Model_Order::STATUS_CONFRIM){ ?>
                $("#setProcure").click(function(){
                    var id = $("#allOrderId").val();
                    var procureNo = $("#procureNo").val();
                    if(procureNo == ""){
                        alert("订单号不能为空");
                        return false;
                    }
                    $.post("/admini/purchase/setprocure",{"id":id,"procureNo":procureNo},function(data){
                        if(data == 1){
                            alert("下单成功");
                            location.reload();
                        } else if(data == 2){
                            alert("该订单号已存在")
                        } else if(data == 3){
                            alert("不是您受理的，无法修改");
                        } else if(data == 4){
                            alert("订单号不能为空");
                        } else {
                            alert("出现未知错误");
                        }
                    });
                });
            <?php }?>
            <?php if($this->order->Status == Application_Model_Order::STATUS_UNSEND){ ?>
                $("#setLogistics").click(function(){
                    var logistics = $("#logistics").val();
                    var logisticsNo = $("#logisticsNo").val();
                    if(logisticsNo == ""){
                        alert("物流单号不能为空");
                        return ;
                    }
                    var id = $("#allOrderId").val();
                    $.post("/admini/purchase/setlogistics",{"id":id,"logistics":logistics,'logisticsNo':logisticsNo},function(data){
                        if(data == 1){
                            alert("更新成功");
                            location.reload();
                        } else if(data == 2){
                            alert("该订单号已存在")
                        } else if(data == 3){
                            alert("不是您受理的，无法修改");
                        } else if(data == 4){
                            alert("物流单号不能为空");
                        }
                    });
                });
            <?php }?>
            /**
             * 入库
             */
            $("#setInStore").click(function(){
                var id = $("#allOrderId").val();
                $.post("/admini/purchase/setinstore/",{"id":id},function(data){
                    if(data == 1){
                        alert("入库成功");
                        location.reload();
                    } else if (data == 3){
                        alert("该状态下订单不能设置入库");
                    } else {
                        alert("出现未知错误");
                    }
                });
            });

            $("#splitOrder").click(function(){
                $(".splitTr").hide();
                var idlist = '';
                $('input[class="SplitCheck"]:checked').each(function(){    
                    var splitid = $(this).val()
                    idlist+= splitid+',';
                    $(".splitTr"+splitid).show();
                });
                if(idlist == ""){
                    alert("请选择需要拆分的商品！");
                    return ;
                }
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#splitOrderTitle").closest("li").addClass("wt_on");
                $("#splitOrderTitle").closest("li").show();
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#splitOrderConent").show();
            });
            $("#subSplitOrder").click(function(){
                var result = "";
                $('input[name="splitNum"]').each(function(){  
                    var goodsId = $(this).attr("goodsId");
                    if(!$(".splitTr"+goodsId).is(":hidden")){
                        result += goodsId+":"+$(this).val()+",";
                    }
                });  
                var id = $("#allOrderId").val();
                if(confirm("您确定拆分该订单？","提示信息")){
                    $.post("/admini/purchase/splitorder",{"id":id,"splitnum":result},function(data){
                        if (data == 1) {
                            alert("拆分成功");
                            location.reload();
                        } else if(data == 2) {
                            alert("只能拆分受理订单");
                        } else if(data == 3) {
                            alert("拆分数量不对");
                        } else if(data == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            $(".retanchuang").click(function(){
                $(".houtai_overlay").hide();
                $(".tanchuang").hide();
            });
            $(".nui-msgbox-close").click(function(){
                $(".houtai_overlay").hide();
                $(".tanchuang").hide();
            });
            $(".reserveOrder").click(function(){
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#reserveOrderTitle").closest("li").addClass("wt_on");
                $("#reserveOrderTitle").closest("li").show();
                var id = $("#allOrderId").val();
                $.post("/admini/purchase/getreserveorder",{"id":id},function(data){
                    if(data.reserveTime){
                        $("#reserveOrderConent #reserveTime").val(data.reserveTime);
                    }
                });
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#reserveOrderConent").show();
            });
            $("#subReserveOrder").click(function(){
                var id = $("#allOrderId").val();
                var reserveTime = $("#reserveTime").val();
                var reserveCause = $("#reserveCause").val();
                if(reserveTime == "" || reserveCause == ""){
                    alert("预订时间和预订原因不能为空!");
                    return ;
                }
                if(confirm("您确定该代购为预订订单，发货时间为"+reserveTime+"？","提示信息")){  
                    $.post("/admini/purchase/setreserveorder",{"id":id,"reserveTime":reserveTime,"reserveCause":reserveCause},function(data){
                        if (data == 1) {
                            alert("预定成功");
                            location.reload();
                        } else if(data == 2) {
                            alert("该订单状态下不可能预定");
                        } else if(data == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            /**
             * 问题信息展示
             */
            $(".showProblem").click(function(){
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#isProblemTitle").closest("li").addClass("wt_on");
                $("#isProblemTitle").closest("li").show();
                $("#isProblemConent .wt_center").html("");
                var id = $("#allOrderId").val();
                $.post("/admini/purchase/problemshow/",{"orderId":id},function(data){
                    if (data.type == 1) {
                        var html = "";
                        $.each(data.arrProblem, function(key, val) {
                            html += '<div class="'+(val.issueetype==1?'wt_uuch':'wt_kehu')+'">';
                            html += '<h2>'+(val.issueetype==1?'悠奇客服':('回复人：<a href="/admini/manageuser/userdetail/id/'+val.userId+'" target="_blank">'+val.userName+'</a>'));
                            html += '<span>'+val.dateCreated+'</span></h2>';
                            html += '<p>'+val.content+'</p></div>';
                        });
                        $("#isProblemConent .wt_center").html(html);
                    }
                });
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#isProblemConent").show();
            });
            /**
            * 添加问题信息
             */
            $("#subIsProblem").click(function(){
                var content  = $("#content").val();
                var id       = $("#allOrderId").val();
                var repay    = $("#repay").val();
                var repaysum = $("#repay-sum").val();
                if(repay == 1 && isNaN(repaysum)){
                    alert("补交金额需要为数字！");
                    return false;
                }
                if(content == ""){
                    alert("问题内容不能为空！");
                    return false;
                }
                $.post(
                    "/admini/purchase/addproblem/",
                    {
                        "id"        : id,
                        "content"   : content,
                        "repay"     : repay,
                        "repaysum"  : repaysum
                    },
                    function(data){
                        if(data.type == 1){
                            alert("问题代购设置成功");
                            location.reload();
                        } else if (data.type == 2){
                            alert("问题内容不能为空！");
                        } else if (data.type == 9){
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                        $("#content").val("");
                    }
                );
            });
             /**
            * 问题解决
             */
            $(".SolveComplete").click(function(){
                var id = $("#allOrderId").val();
                if(confirm("您确认该代购订单的问题已经解决？","提示信息")){
                    $.post("/admini/purchase/solveproblem",{"id":id},function(data){
                        if (data == 1) {
                            alert("解决成功");
                            location.reload();
                        } else if(data == 2) {
                            alert("该订单不是问题订单");
                        } else if(data == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            /**
            * 异常信息展示
            */
           $(".abnormalico").click(function(){
               $(".wt_nav ul li").removeClass("wt_on");
               $(".wt_nav ul li").hide();
               $(".wenti_box").hide();
               $("#abnormalTitle").closest("li").addClass("wt_on");
               $("#abnormalTitle").closest("li").show();
               $("#abnormalConent .wt_center").html("");
               var id = $("#allOrderId").val();
               $.post("/admini/purchase/abnormalshow/",{"orderId":id},function(data){
                   if (data.type == 1) {
                       var html = "<table style='width:680px;'><tr class='abnormalTr'><td style='width:10%;'>添加人</td><td style='width:20%;'>时间</td><td>内容</td><td style='width:10%;'>状态</td><td style='width:10%;'>操作</td></tr>";
                       if(data.orderAbnrmal){
                           html += "<tr class='abnormalTr'><td colspan='2'>整个包裹问题：</td><td>订单编号："+data.orderAbnrmal.orderNum+"</td><td colspan='2'>订单标识符："+data.orderAbnrmal.SoleNo+"</td></tr>";
                           $.each(data.orderAbnrmal.arrAbnormal,function(orderKey,orderVal){
                               html += "<tr class='AbnormalKey"+orderKey+"'><td>"+orderVal.operator+"</td>";
                               html += "<td>"+orderVal.dateCreated+"</td>";
                               html += "<td>"+orderVal.content+"</td>";
                               html += "<td>"+orderVal.statusName+"</td><td>";
                               if(orderVal.status == 0){
                                   html += "<a href='javascript:void(0)' class='indexa disposeAbnormal' name='"+orderVal+"'>处理</a>";
                               } else {
                                   html += "<font style='color:#c00'>已处理</font>";
                               }
                               html += "</td></tr>";
                               if(orderVal.arrImg){
                                   html += "<tr class='AbnormalImg"+orderKey+"'><td>问题图片：</td><td colspan='4'><div style='width:100%;height:56px;padding:3px;overflow: auto;'>";
                                   $.each(orderVal.arrImg,function(imgItem,imgVal){
                                      html += "<a href='<?php echo $this->cdn;?>"+imgVal.imgUrl+"' target='_blank'><img src='<?php echo $this->cdn;?>"+imgVal.img+"' style='width:50px;height:50px;margin-right:5px' /></a>"; 
                                   });
                                   html += "</div></td></tr>";
                               }
                               html += "<tr class='AbnormalDispose"+orderKey+" abnormalTr'><td>处理异常：</td><td colspan='4'><div class='disposeContent"+orderVal+"' style='width:98%;'><ul>";
                               if(orderVal.arrTrack){
                                   $.each(orderVal.arrTrack,function(trackKey,trackVal){
                                       html += "<li>"+trackVal.dateCreated+"&nbsp;&nbsp;"+trackVal.content+"&nbsp;&nbsp;-----&nbsp;&nbsp;"+trackVal.operator+"</li>";
                                   }) ;
                               }
                               html += "</ul></div></td></tr>";
                           });
                       }
                       if(data.itemAbnrmal){
                           $.each(data.itemAbnrmal,function(key,val){
                               html += '<tr class="abnormalTr"><td style="line-height: 20px" class="w0" colspan="5"><div style="float:left;width: 55px;margin: 5px 0px;">';
                               html += '<img src="'+val.img+'" width="50px" height="50px" style="vertical-align:middle;margin-top: 5px;"></div><div style="float:left;width: 90%;">&nbsp;&nbsp;';
                               html += val.name+'</div><div style="float:left;color:#666;width: 90%;">&nbsp;&nbsp;'+val.alias+'</div>';
                               html += '</td></tr>';
                               $.each(val.arrAbnormal,function(AbnormalKey,AbnormalVal){
                                   html += "<tr class='AbnormalKey"+AbnormalKey+"'><td>"+AbnormalVal.operator+"</td>";
                                   html += "<td>"+AbnormalVal.dateCreated+"</td>";
                                   html += "<td>"+AbnormalVal.content+"</td>";
                                   html += "<td>"+AbnormalVal.statusName+"</td><td>";
                                   if(AbnormalVal.status == 0){
                                       html += "<a href='javascript:void(0)' class='indexa disposeAbnormal' name='"+AbnormalKey+"'>处理</a>";
                                   } else {
                                       html += "<font style='color:#c00'>已处理</font>";
                                   }
                                   html += "</td></tr>";
                                   if(AbnormalVal.arrImg){
                                       html += "<tr class='AbnormalImg"+AbnormalKey+"'><td>问题图片：</td><td colspan='4'><div style='width:100%;height:56px;padding:3px;overflow: auto;'>";
                                       $.each(AbnormalVal.arrImg,function(imgItem,imgVal){
                                          html += "<a href='<?php echo $this->cdn;?>"+imgVal.imgUrl+"' target='_blank'><img src='<?php echo $this->cdn;?>"+imgVal.img+"' style='width:50px;height:50px;margin-right:5px' /></a>"; 
                                       });
                                       html += "</div></td></tr>";
                                   }
                                   html += "<tr class='AbnormalDispose"+AbnormalKey+" abnormalTr'><td>处理异常：</td><td colspan='4'><div class='disposeContent"+AbnormalKey+"' style='width:98%;'><ul>";
                                   if(AbnormalVal.arrTrack){
                                       $.each(AbnormalVal.arrTrack,function(trackKey,trackVal){
                                           html += "<li>"+trackVal.dateCreated+"&nbsp;&nbsp;"+trackVal.content+"&nbsp;&nbsp;-----&nbsp;&nbsp;"+trackVal.operator+"</li>";
                                       }) ;
                                   }
                                   html += "</ul></div></td></tr>";
                               });
                           });
                       }
                       html += '</table>';
                       $("#abnormalConent .wt_center").html(html);
                       if(data.lossUser){
                           var ahtml = "由"+data.lossUser+"造成的损耗，已记录";
                       } else {
                           var ahtml = '<a class="indexa loss" href="javascript:void(0);" ><span>登记代购人员出错</span></a>';
                       }
                       $("li.lossLog").html(ahtml);
                   }
               });
               $(".houtai_overlay #orderId").val(id);
               $(".houtai_overlay").show();
               $(".tanchuang").show();
               $("#abnormalConent").show();
           });
           $(".disposeAbnormal").live("click",function(){
               $("#abnormalConent .wt_center tr").removeClass("bColor");
               var abnormalId = $(this).attr("name");
               $(this).parents("tr").addClass("bColor");
               $("#abnormalConent #abnormalId").val(abnormalId);
               $("#abnormalConent .wt_caozuo").show();
               $("#abnormalConent .wt_type").show();
           });
           /**
           * 添加异常说明
            */
           $("#subAbnormal").click(function(){
               var id = $("#allOrderId").val();
               var abnormalId = $("#abnormalConent #abnormalId").val();
               var abnormalType = $("#abnormalConent .wt_type input[name='isAbnormal']:checked").val();
               var abnormalCause = $("#abnormalCause").val();
               if(abnormalCause == ""){
                   alert("问题内容不能为空！");
                   return false;
               }
               if(abnormalId == ""){
                   alert("出现未知错误，请刷新在试！");
                   return false;
               }
               $.post("/admini/purchase/addabnormal/",{"id":id,"cause":abnormalCause,"abnormalId":abnormalId,"abnormalType":abnormalType},function(data){
                   if(data.type == 1){
                       var html = "<li>"+data.dateCreated+"&nbsp;&nbsp;"+data.cause+"&nbsp;&nbsp;-----&nbsp;&nbsp;"+data.operator+"</li>";
                       $(".disposeContent"+abnormalId+" ul").append(html);
                       $(".AbnormalImg"+abnormalId).removeClass("abnormalTr");
                       $(".AbnormalDispose"+abnormalId).addClass("abnormalTr");
                       if(abnormalType == 1){
                           $(".disposeAbnormal[name='"+abnormalId+"']").parent("td").html("<font style='color:#c00'>已处理</font>");
                           $("#abnormalConent .wt_type").hide();
                           $("#abnormalConent .wt_caozuo").hide();
                           $("#abnormalConent .abnormalCause").val("");
                           $("#abnormalConent .wt_center tr").removeClass("bColor");
                       }
                   } else if (data.type == 2){
                       alert("问题内容不能为空！");
                   } else if (data.type == 9){
                       alert("该订单不是您受理的");
                   } else {
                       alert("发生未知错误，请重新操作");
                   }
                   $("#abnormalCause").val("");
               });
           });
            
            /**
            * 代购人员出错
             */
             $(".loss").live("click",function(){
                var id = $("#allOrderId").val();
                $("#lossUser").val("");
                $("#lossMoney").val("");
                $("#lossReason").val("");
                $.post("/admini/purchase/lossshow",{"id":id},function(data){
                    if (data.type == 1) {
                        $(".wt_nav ul li").removeClass("wt_on");
                        $(".wt_nav ul li").hide();
                        $(".wenti_box").hide();
                        $("#lossTitle").closest("li").addClass("wt_on");
                        $("#lossTitle").closest("li").show();
                        $(".houtai_overlay").show();
                        $(".tanchuang").show();
                        $("#lossConent").show();
                        if(data.lossUser){
                            $("#lossUser").val(data.lossUser);
                        } else {
                            $("#lossUser").removeAttr("readonly");
                        }
                        $("#lossMoney").val(data.lossMoney);
                    } else {
                        alert("发生未知错误，请重新操作");
                    }
                });
             });
             $("#subLost").click(function(){
                 var id = $("#allOrderId").val();
                 var lossUser = $("#lossUser").val();
                 var lossMoney = $("#lossMoney").val();
                 var lossReason = $("#lossReason").val();
                 if(lossUser == ""){
                     alert("造成损耗的下单人不能为空！");
                     return ;
                 }
                 if(lossMoney == ""){
                     alert("造成损耗的金额不能为空！");
                     return ;
                 }
                 if(lossReason == ""){
                     alert("损耗的原因不能为空!");
                     return ;
                 }
                 if(confirm("您确认是该异常订单的下单人："+lossUser+"造成"+lossMoney+"元的损耗？","提示信息")){
                     $.post("/admini/purchase/subloss",{"id":id,"lossUser":lossUser,"lossMoney":lossMoney,"lossReason":lossReason},function(data){
                         if(data == 1){
                            var ahtml = "由"+lossUser+"造成的损耗，已记录";
                            $("span.lossLog").html(ahtml);
                            $(".wt_nav ul li").removeClass("wt_on");
                            $(".wt_nav ul li").hide();
                            $(".wenti_box").hide();
                            $("#abnormalTitle").closest("li").addClass("wt_on");
                            $("#abnormalTitle").closest("li").show();
                            $(".houtai_overlay #orderId").val(id);
                            $(".houtai_overlay").show();
                            $(".tanchuang").show();
                            $("#abnormalConent").show();
                         } else if (data == 2){
                             alert("造成损耗的下单人、金额以及原因不能为空！");
                         } else {
                             alert("发生未知错误，请重新操作");
                         }
                     });
                 }
             });
            /**
            * 手工操作历史
             */
            $(".setHandwork").click(function(){
                var id = $("#allOrderId").val();
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#handworkTitle").closest("li").addClass("wt_on");
                $("#handworkTitle").closest("li").show();
                $.post("/admini/purchase/handworkshow/",{"orderId":id},function(data){
                    if (data.type == 1) {
                       var html = "";
                       $.each(data.arrCheck,function(key,val){
                          html += "<p><span>"+val.dateCreated+"</span><span style='margin-left:20px;'>"+val.applyName+"申请"+val.checkType+"</span>" ;
                          html += "<span style='margin-left:20px;'>原因:"+val.reason+"</span><span style='margin-right: 20px;float: right;'>"+val.statusName+"</span>";
                       });
                       $(".checkHistory").html(html);
                    }
                });
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#handworkConent").show();
            });
            /**
            * 添加手工操作
             */
            $("#subHandworkr").click(function(){
                var id = $("#allOrderId").val();
                var hendworkType = $("#hendworkType").val();
                var hendworkName = $("#hendworkType option[value='"+hendworkType+"']").text();
                var handworkMoney = $("#handworkMoney").val();
                var handworkReason = $("#handworkReason").val();
                if(handworkMoney == "" || handworkMoney == 0){
                    alert("金额不能为空或零");
                    return ;
                }
                if(handworkReason == ""){
                    alert("原因不能为空");
                    return ;
                }
                if(confirm("您确认为该订单该用户"+hendworkName+handworkMoney+"元？","")){
                    $.post("/admini/purchase/sethandwork/",{"id":id,"hendworkType":hendworkType,"handworkMoney":handworkMoney,"handworkReason":handworkReason},function(data){
                        if(data == 1){
                            alert("手工操作成功！");
                            location.reload();
                        } else if (data == 2){
                            alert("操作金额超代购总价！");
                        } else if (data == 3){
                            alert("用户余额不足！");
                        } else if (data == 9){
                            alert("没有权限操作！请更改受理人！");
                        } else {
                            alert("出现未知错误，请刷新再试");
                        }
                    });
                }
            });
            $(".addLog").click(function(){
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#addLogTitle").closest("li").addClass("wt_on");
                $("#addLogTitle").closest("li").show();
                $("#addLogContent").val("");
                $("#addLogTime").val("<?php echo date("Y-m-d H:i:s");?>");
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#addLogConent").show();
            });
            $("#subAddLog").click(function(){
                var id = $("#allOrderId").val();
                var addLogTime = $("#addLogTime").val();
                var addLogContent = $("#addLogContent").val();
                var logIsVisible = $("#logIsVisible").val();
                if(addLogTime == ""){
                    alert("时间不能为空");
                    return ;
                }
                if(addLogContent == ""){
                    alert("日志内容不能为空");
                    return ;
                }
                $.post("/admini/purchase/addtracklog",{"id":id,"addLogTime":addLogTime,"addLogContent":addLogContent,"logIsVisible":logIsVisible},function(data){
                    if(data == 1){
                        alert("添加成功");
                        location.reload();
                    } else {
                        alert("发生未知错误，请重新操作");
                    }
                });
            });
            $(".editInterior").click(function(){
                var status = $(this).attr("name");
                var statusname = $(this).text();
                if(confirm("您确定修改该订单的状态为"+statusname+"？","提示信息")){
                    var id = $("#allOrderId").val();
                    $.post("/admini/purchase/editinterior",{"id":id,"status":status},function(data){
                        if (data == 1) {
                            alert("修改成功");
                            location.reload();
                        } else if(data == 2) {
                            alert("不能修改未付款和已经取消的订单");
                        } else if(data == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            $(".editOperator").click(function(){
                var id = $("#allOrderId").val();
                if(confirm("您确定该代购的受理人更改为您？","提示信息")){  
                    $.post("/admini/purchase/editoperator",{"id":id},function(data){
                        if (data == 1) {
                            alert("修改成功");
                            location.reload();
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            $("#cancel").click(function(){
                var id = $("#allOrderId").val();
                if(confirm("您确认取消该订单吗","提示信息")){
                    $.post("/admini/purchase/cancel",{"id":id},function(data){
                        if (data.type == 1) {
                            alert("取消成功");
                            location.reload();
                        } else if(data.type == 2) {
                            alert("不能取消该状态下的订单");
                        } else if(data.type == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }
            });
            $(".SingleRetuenMoney").click(function(){
                var id = $("#allOrderId").val();
                var singleId = $(this).attr("name");
                if(confirm("您确认该产品单项退款?","提示信息")){
                    $.post("/admini/purchase/singlereturn",{"id":id,"singleId":singleId},function(data){
                        if (data == 1) {
                            alert("退款成功");
                            location.reload();
                        } else if(data == 2) {
                            alert("不能退款该状态下的订单");
                        } else if(data == 3) {
                            alert("该商品已经退款了");
                        } else if(data == 9) {
                            alert("该订单不是您受理的");
                        } else {
                            alert("发生未知错误，请重新操作");
                        }
                    });
                }            
            });
            $(".addRemark").click(function(){
                $(".wt_nav ul li").removeClass("wt_on");
                $(".wt_nav ul li").hide();
                $(".wenti_box").hide();
                $("#addRemarkTitle").closest("li").addClass("wt_on");
                var id = $(this).attr("name");
                $.post("/admini/purchase/getcomment",{"id":id},function(data){
                    if(data){
                        $("#addRemarkConent #remark").val(data);
                    } else {
                        $("#addRemarkConent #remark").val("");
                    }
                });
                $(".houtai_overlay #orderId").val(id);
                $(".houtai_overlay").show();
                $(".tanchuang").show();
                $("#addRemarkConent").show();
            });
            $("#subAddRemark").click(function(){
            var orderId = $(".houtai_overlay #orderId").val();
            var remark = $("#addRemarkConent #remark").val(); 
            if (remark == '')
            {
                alert("请输入说明信息.");
                return;
            }
            $.post("/admini/purchase/setcomment",{"orderId":orderId,"comment":remark},function(data){
                if (data == 1) {
                    alert("提交成功");
                    $("#itemDescription" + orderId).text(remark);
                } else {
                    alert("发生未知错误，请重新操作");
                }
                $(".houtai_overlay").hide();
                $(".tanchuang").hide();
            });
        });
        
        <?php } ?>
    });
    $(function(){
        $(".soleNo").each(function() {
            //Create a new clipboard client
            var clip = new ZeroClipboard.Client();
            ZeroClipboard.setMoviePath("/js/clip/ZeroClipboard.swf");
            clip.setHandCursor( true );
            $.bind(window, "resize", function(){ 
                clip.reposition(); 
            });
            //Glue the clipboard client to the last td in each row
            clip.glue(this);
            var tThis = this;
            //Grab the text from the parent row of the icon
            var code = $(this).text() ;
            var add = "南山区朗山二号路3号悠奇大厦 "+code+" 号邮箱";
            clip.setText(add); 
            
            clip.addEventListener('complete', function() {
                  $(tThis).text("已复制");
            });
        });
    });
    function repayHandle(obj) {
        if ($(obj).attr('checked') == 'checked') {
            $('#repay').val('1');
            $("#repay-sum").removeAttr('readonly');
        } else {
            $('#repay').val('0');
            $("#repay-sum").attr('readonly', 'true');
        }   
    }
</script>
